
package gui.panels;

import gui.model.DrinkModel;
import gui.panels.components.MmiButton;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Image;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.LineBorder;

/**
 *
 * @author JtR
 */
public class NavigationPanel extends JPanel {
    public MmiButton previousButtonCoffee, nextButtonCoffee, previousButtonTea, nextButtonTea;
    private JLabel description;
    
    public NavigationPanel(ActionListener listener) {
        setPreferredSize(new Dimension(720, 100));
        setBorder(new LineBorder(Color.BLACK));

        setLayout(new GridBagLayout());

        GridBagConstraints c = new GridBagConstraints();

        c.gridy = 0;
        c.gridx = 0;
        c.insets = new Insets(0, 20, 0, 0);
        previousButtonCoffee = new MmiButton("res/kaffeepause/kaffeepfeillinks.png", 100);
        previousButtonCoffee.setHorizontalTextPosition(JButton.CENTER);
        previousButtonCoffee.setVerticalTextPosition(JButton.BOTTOM);
        previousButtonCoffee.addActionListener(listener);
        add(previousButtonCoffee, c);
        previousButtonTea = new MmiButton("res/teetime/teepfeillinks.png", 100);
        previousButtonTea.setHorizontalTextPosition(JButton.CENTER);
        previousButtonTea.setVerticalTextPosition(JButton.BOTTOM);
        previousButtonTea.addActionListener(listener);
        add(previousButtonTea, c);

        c.gridx = 1;
        c.weightx = 1;
        c.insets = new Insets(0, 0, 0, 0);
        description = new JLabel();
        description.setFont(new Font(description.getFont().getName(), Font.BOLD, 20));
        add(description, c);

        c.gridx = 2;
        c.weightx = 0;
        c.insets = new Insets(0, 0, 0, 20);
        nextButtonCoffee = new MmiButton("res/kaffeepause/kaffeepfeilrechts.png", 100);
        nextButtonCoffee.setHorizontalTextPosition(JButton.CENTER);
        nextButtonCoffee.setVerticalTextPosition(JButton.BOTTOM);
        nextButtonCoffee.addActionListener(listener);
        add(nextButtonCoffee, c);
        nextButtonTea = new MmiButton("res/teetime/teepfeilrechts.png", 100);
        nextButtonTea.setHorizontalTextPosition(JButton.CENTER);
        nextButtonTea.setVerticalTextPosition(JButton.BOTTOM);
        nextButtonTea.addActionListener(listener);
        add(nextButtonTea, c);
    }
    
    public void setDescription(String text) {
        description.setText(text);
    }
    
    public void setNextButtonEnabled(boolean value) {
        nextButtonCoffee.setEnabled(value);
        nextButtonTea.setEnabled(value);
    }
    
    public void setPreviousButtonEnabled(boolean value) {
        previousButtonCoffee.setEnabled(value);
        previousButtonTea.setEnabled(value);
    }
    
    public void updateButtons() {
        if(DrinkModel.getInstance().getDrink() == DrinkModel.Drink.TEA) {
            previousButtonCoffee.setVisible(false);
            nextButtonCoffee.setVisible(false);
            previousButtonTea.setVisible(true);
            nextButtonTea.setVisible(true);
        } else {
            previousButtonCoffee.setVisible(true);
            nextButtonCoffee.setVisible(true);
            previousButtonTea.setVisible(false);
            nextButtonTea.setVisible(false);
        }
    }
}

